<?php
namespace Admin\Controller;

class UserController extends CommonController{
    
    //会员列表 
    public function index(){

        $this->where = array();
        I('get.keywords') && $this->where['nickname'] = array('like','%'.I('get.keywords').'%');
        $this->order = 'create_date desc';
        parent::index();
    }
    
    //积分记录
    public function cent_log(){

        $where = array();
        I('get.keywords') && $where['nickname'] = array('like','%'.I('get.keywords').'%');
        I('user_id') && $where['user_id'] = I('user_id');
        $dataPage = D('CentLog')->relation(true)->getPager($where);
        $this->assign('list',$dataPage['data']);
        $this->assign('page',$dataPage['page']);
        $this->display();
    }

    //余额记录
    public function balance(){
        
        $where = array();
        I('get.keywords') && $where['sense'] = array('like','%'.I('get.keywords').'%');
        I('user_id') && $where['user_id'] = I('user_id');
        $where['pay_type'] = '4';
        $dataPage = D('PayLog')->relation(true)->getPager($where);
        $this->assign('list',$dataPage['data']);
        $this->assign('page',$dataPage['page']);
        $this->display();

    }

    //提现记录
    public function user_cent(){

         $where = array();
        I('get.keywords') && $where['sense'] = array('like','%'.I('get.keywords').'%');
        I('user_id') && $where['user_id'] = I('user_id');
        $where['pay_type'] = '6';
        $dataPage = D('PayLog')->relation(true)->getPager($where);
        $this->assign('list',$dataPage['data']);
        $this->assign('page',$dataPage['page']);
        $this->display();
    }

    public function set_status(){

        !I('post.id') && $this->error('id不存在');
        $res = D('PayLog')->where(array('id'=>I('post.id')))->save(array('pay_status'=>2));
        $res === false ? $this->error('处理失败'):$this->success('处理成功');
    }


    public function user_detail(){
        $id = intval(I('post.id'));
        $data = D('user')->where("id='$id'")->find();
        $this->assign('user',$data);
        $this->display();
    }

}
